package com.itheima.app.controller;

import com.itheima.app.manager.TestSoulManager;
import com.itheima.domain.db.Answers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Autor JiangYunTian
 * @Date 2022/11/10
 * @Function 测灵魂Controller
 */
@RestController
public class TestSoulController {

    @Autowired
    private TestSoulManager testSoulManager;

    //测灵魂查询问卷
    @GetMapping("/testSoul")
    public ResponseEntity findQuestionnaire(){
        return testSoulManager.findQuestionnaire();
    }


    //提交问卷
    @PostMapping("/testSoul")
    public ResponseEntity submitQuestionnaire(@RequestBody Map<String,List<Answers>> param){
        List<Answers> answers = param.get("answers");
        return testSoulManager.submitQuestionnaire(answers);
    }

    //查看结果
    @GetMapping("/testSoul/report/{reportId}")
    public ResponseEntity findReportById(@PathVariable String reportId){
        return testSoulManager.findReportById(reportId);
    }
}
